const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
module.exports = {
    mode: 'development',
    entry: [path.join(__dirname, 'src/main.js')],
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    stats: {
        children: false
    },
    module: {
        rules: [
             /*{
                test: /\.(gif|jpg|jpeg|png|svg|ico)$/,
                use: {
                    loader: 'url-loader',
                    options: {
                        outputPath: 'assets/',
                        // name: '[name].[ext]?[hash]',
                        esModule: false,
                        // limit: 10240,
                    }
                }
            },*/
            {
                test: /\.(png|jpg|gif|ico)$/,
                use: [
                    {
                        loader: 'file-loader',
                        options: {
                            outputPath: 'assets/',
                            name: '[name].[ext]?[hash]',
                            limit: 2048,
                            //publichPath: './',
                            esModule: false
                        }
                    }
                ]
            },
            {
                test: /\.vue$/, // 处理 .vue 文件
                loader: 'vue-loader'
            },
            {
                test: /\.css|less$/,
                use: [

                    'style-loader',
                    'css-loader',
                    'less-loader'
                ]
            },

            /*{
                test: /.html$/,     // 处理html 
                use: {
                    loader: 'html-loader',
                    options: {
                        attrs: ['img:src', 'a.href', 'link.href',':data-src', ":src"]
                    }
                }
            }*/

            /*　{
             test: /\.(gif|jpg|jpeg|png|svg|ico)$/,
             use: {
                 loader: 'url-loader',
                 options: {
                     outputPath: 'assets/',
                     esModule: false, 
                     limit: 10240
                 }
             }
             }*/

        ]
    },
    plugins: [
        new VueLoaderPlugin(),
        new HtmlWebpackPlugin({
            title: "hello",
            template: './public/index.html',
            templateParameters:{
                BASE_URL: './public/'
            }
        })
    ]
}